package com.user.service.impl;

import java.util.List;

import com.user.dao.UserDao;
import com.user.modal.User;
import com.user.service.UserService;

/**
 * Project			:myws
 * JDK version		:jdk1.6.0
 * Version          :1.0
 * Date             :2012-6-26
 * Author		    :陶尚明
 * Comments         :用户service实现类
 */
public class UserServiceImpl implements UserService {
	//定义用户dao
	private UserDao userDao;
	
	/** 
	* FunName:           registUser 
	* Description :      注册用户
	* @param：                             用户实体类 User
	* @return:           返回状态 Integer(-1:失败 其他:注册用户id) 
	* @Author:           陶尚明 
	* @Create Date:      2012-06-26 
	*/ 
	@Override
	public Integer registUserTran(User user) throws Exception {
		
		Integer retValue=new Integer(-1);
		try{
			//先进行用户重复性查询
			List<User> userList=userDao.findUserList(user);
			//若不存在重复
			if(userList==null || userList.size()==0){
				//执行新增,并且返回新增用户的id值
				retValue=userDao.insertUser(user);
			}
		}catch(Exception ex){
			throw new RuntimeException("ex");
		}
		return retValue;
	}

	/**
	 * @param userDao the userDao to set
	 */
	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}

	/**
	 * @return the userDao
	 */
	public UserDao getUserDao() {
		return userDao;
	}

}
